{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Molecule and Atom Introduction\n",
    "\n",
    "This tutorial is meant to illustrate some of the properties and functionality available within the `Molecule` class. Individual pieces of the molecule can be called and operated on, or the molecule can be operated on as a whole. Let's start with understanding how to work with some of the properties of a molecule."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Imports necessary packages and checks the version of molli.\n",
    "import molli as ml \n",
    "ml.aux.assert_molli_version_min(\"1.0a\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Molecule"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A `Molecule` can be loaded in very quickly via a file path or available string. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Molecule(name='dendrobine', formula='C16 H25 N1 O2')"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Loads in a molecule\n",
    "mol1 = ml.load(ml.files.dendrobine_mol2)\n",
    "mol1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An existing `Molecule` object can be quickly copied as is and coordinates can be quickly manipulated and combined. The below example illustrate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "88\n",
      "unknown\n",
      "N         1.296000    -0.231900     1.267000\n",
      "C         0.057300    -0.022600     2.122700\n",
      "C        -1.097400    -0.473800     1.205900\n",
      "C        -0.428400    -0.411300    -0.168700\n",
      "C         0.868300     0.359800    -0.000400\n",
      "C         2.456200     0.441700     1.836100\n",
      "C        -2.432800     0.265900     0.983200\n",
      "C        -2.655300     0.247200    -0.580100\n",
      "C        -1.242800     0.562600    -1.016300\n",
      "C         1.535300     0.579000    -1.417900\n",
      "O         1.341000     2.036300    -1.650700\n",
      "C         0.078200     2.229100    -2.216600\n",
      "C        -0.597700     0.853900    -2.402000\n",
      "O        -0.413500     3.318000    -2.455200\n",
      "C         0.760200     0.167800    -2.700100\n",
      "C         0.781200    -1.214100    -3.377300\n",
      "H         1.242600     0.768400    -3.498200\n",
      "H        -1.179400     1.558000    -0.537700\n",
      "H         0.651600     1.395200     0.317400\n",
      "H        -1.372200    -1.491000     1.513400\n",
      "C        -0.282800    -1.883500    -0.595700\n",
      "C         2.177500    -1.841200    -3.321500\n",
      "C         0.348500    -1.100600    -4.851400\n",
      "H         0.059000    -1.900900    -2.947800\n",
      "H        -0.064900     1.026400     2.419800\n",
      "H         0.116200    -0.640800     3.024400\n",
      "H         2.715000    -0.004900     2.801900\n",
      "H         2.292700     1.514700     1.987400\n",
      "H         3.325500     0.316200     1.181800\n",
      "H        -2.371600     1.296200     1.353400\n",
      "H        -3.263900    -0.226100     1.498200\n",
      "H        -3.381000     1.006900    -0.883600\n",
      "H        -2.993400    -0.735800    -0.922200\n",
      "H         2.608800     0.379800    -1.439400\n",
      "H        -1.292900     0.877200    -3.242300\n",
      "H        -0.307500    -2.585400     0.247500\n",
      "H         0.692000    -2.089000    -1.031900\n",
      "H        -1.094300    -2.190400    -1.261400\n",
      "H         2.179500    -2.824100    -3.804900\n",
      "H         2.517600    -1.982200    -2.291400\n",
      "H         2.914300    -1.213500    -3.834300\n",
      "H         0.352200    -2.085900    -5.330700\n",
      "H         1.023200    -0.452000    -5.421000\n",
      "H        -0.665200    -0.696700    -4.934600\n",
      "N        51.296000    -0.231900     1.267000\n",
      "C        50.057300    -0.022600     2.122700\n",
      "C        48.902600    -0.473800     1.205900\n",
      "C        49.571600    -0.411300    -0.168700\n",
      "C        50.868300     0.359800    -0.000400\n",
      "C        52.456200     0.441700     1.836100\n",
      "C        47.567200     0.265900     0.983200\n",
      "C        47.344700     0.247200    -0.580100\n",
      "C        48.757200     0.562600    -1.016300\n",
      "C        51.535300     0.579000    -1.417900\n",
      "O        51.341000     2.036300    -1.650700\n",
      "C        50.078200     2.229100    -2.216600\n",
      "C        49.402300     0.853900    -2.402000\n",
      "O        49.586500     3.318000    -2.455200\n",
      "C        50.760200     0.167800    -2.700100\n",
      "C        50.781200    -1.214100    -3.377300\n",
      "H        51.242600     0.768400    -3.498200\n",
      "H        48.820600     1.558000    -0.537700\n",
      "H        50.651600     1.395200     0.317400\n",
      "H        48.627800    -1.491000     1.513400\n",
      "C        49.717200    -1.883500    -0.595700\n",
      "C        52.177500    -1.841200    -3.321500\n",
      "C        50.348500    -1.100600    -4.851400\n",
      "H        50.059000    -1.900900    -2.947800\n",
      "H        49.935100     1.026400     2.419800\n",
      "H        50.116200    -0.640800     3.024400\n",
      "H        52.715000    -0.004900     2.801900\n",
      "H        52.292700     1.514700     1.987400\n",
      "H        53.325500     0.316200     1.181800\n",
      "H        47.628400     1.296200     1.353400\n",
      "H        46.736100    -0.226100     1.498200\n",
      "H        46.619000     1.006900    -0.883600\n",
      "H        47.006600    -0.735800    -0.922200\n",
      "H        52.608800     0.379800    -1.439400\n",
      "H        48.707100     0.877200    -3.242300\n",
      "H        49.692500    -2.585400     0.247500\n",
      "H        50.692000    -2.089000    -1.031900\n",
      "H        48.905700    -2.190400    -1.261400\n",
      "H        52.179500    -2.824100    -3.804900\n",
      "H        52.517600    -1.982200    -2.291400\n",
      "H        52.914300    -1.213500    -3.834300\n",
      "H        50.352200    -2.085900    -5.330700\n",
      "H        51.023200    -0.452000    -5.421000\n",
      "H        49.334800    -0.696700    -4.934600\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#This makes a copy of the original Molecule object and all attributes\n",
    "mol2 = ml.Molecule(mol1)\n",
    "\n",
    "#This translates the copy 50 units in the x axis\n",
    "mol2.translate([50,0,0])\n",
    "\n",
    "#This creates a new molecule that combines the original molecule and the new molecule.\n",
    "print((mol1 | mol2).dumps_xyz())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Each `Molecule` object is made up of a few key properties\n",
    "\n",
    "* A `list` of `Atom` objects\n",
    "* A `list` of `Bond` objects\n",
    "* A `numpy` array of XYZ (3D) coordinates of atoms\n",
    "* A `dict` of attributes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Here are the list of atoms\n",
      "[Atom(element=N, isotope=None, label='N', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=O, isotope=None, label='O', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=O, isotope=None, label='O', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0), Atom(element=H, isotope=None, label='H', formal_charge=0, formal_spin=0)]\n",
      "\n",
      "Here are the list of bonds\n",
      "[Bond(a1=42, a2=22, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=41, a2=22, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=43, a2=22, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=22, a2=15, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=40, a2=21, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=38, a2=21, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=16, a2=14, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=15, a2=21, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=15, a2=23, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=15, a2=14, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=21, a2=39, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=34, a2=12, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=14, a2=12, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=14, a2=9, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=13, a2=11, label=None, btype=Double, stereo=Unknown, f_order=1.0), Bond(a1=12, a2=11, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=12, a2=8, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=11, a2=10, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=10, a2=9, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=33, a2=9, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=9, a2=4, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=37, a2=20, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=36, a2=20, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=8, a2=7, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=8, a2=17, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=8, a2=3, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=32, a2=7, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=31, a2=7, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=20, a2=3, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=20, a2=35, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=7, a2=6, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=3, a2=4, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=3, a2=2, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=4, a2=18, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=4, a2=Atom(element=N, isotope=None, label='N', formal_charge=0, formal_spin=0), label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=6, a2=2, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=6, a2=29, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=6, a2=30, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=28, a2=5, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=2, a2=19, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=2, a2=1, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=Atom(element=N, isotope=None, label='N', formal_charge=0, formal_spin=0), a2=5, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=Atom(element=N, isotope=None, label='N', formal_charge=0, formal_spin=0), a2=1, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=5, a2=27, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=5, a2=26, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=1, a2=24, label=None, btype=Single, stereo=Unknown, f_order=1.0), Bond(a1=1, a2=25, label=None, btype=Single, stereo=Unknown, f_order=1.0)]\n",
      "Here are the coordinates of the atoms\n",
      "[[ 1.2960e+00 -2.3190e-01  1.2670e+00]\n",
      " [ 5.7300e-02 -2.2600e-02  2.1227e+00]\n",
      " [-1.0974e+00 -4.7380e-01  1.2059e+00]\n",
      " [-4.2840e-01 -4.1130e-01 -1.6870e-01]\n",
      " [ 8.6830e-01  3.5980e-01 -4.0000e-04]\n",
      " [ 2.4562e+00  4.4170e-01  1.8361e+00]\n",
      " [-2.4328e+00  2.6590e-01  9.8320e-01]\n",
      " [-2.6553e+00  2.4720e-01 -5.8010e-01]\n",
      " [-1.2428e+00  5.6260e-01 -1.0163e+00]\n",
      " [ 1.5353e+00  5.7900e-01 -1.4179e+00]\n",
      " [ 1.3410e+00  2.0363e+00 -1.6507e+00]\n",
      " [ 7.8200e-02  2.2291e+00 -2.2166e+00]\n",
      " [-5.9770e-01  8.5390e-01 -2.4020e+00]\n",
      " [-4.1350e-01  3.3180e+00 -2.4552e+00]\n",
      " [ 7.6020e-01  1.6780e-01 -2.7001e+00]\n",
      " [ 7.8120e-01 -1.2141e+00 -3.3773e+00]\n",
      " [ 1.2426e+00  7.6840e-01 -3.4982e+00]\n",
      " [-1.1794e+00  1.5580e+00 -5.3770e-01]\n",
      " [ 6.5160e-01  1.3952e+00  3.1740e-01]\n",
      " [-1.3722e+00 -1.4910e+00  1.5134e+00]\n",
      " [-2.8280e-01 -1.8835e+00 -5.9570e-01]\n",
      " [ 2.1775e+00 -1.8412e+00 -3.3215e+00]\n",
      " [ 3.4850e-01 -1.1006e+00 -4.8514e+00]\n",
      " [ 5.9000e-02 -1.9009e+00 -2.9478e+00]\n",
      " [-6.4900e-02  1.0264e+00  2.4198e+00]\n",
      " [ 1.1620e-01 -6.4080e-01  3.0244e+00]\n",
      " [ 2.7150e+00 -4.9000e-03  2.8019e+00]\n",
      " [ 2.2927e+00  1.5147e+00  1.9874e+00]\n",
      " [ 3.3255e+00  3.1620e-01  1.1818e+00]\n",
      " [-2.3716e+00  1.2962e+00  1.3534e+00]\n",
      " [-3.2639e+00 -2.2610e-01  1.4982e+00]\n",
      " [-3.3810e+00  1.0069e+00 -8.8360e-01]\n",
      " [-2.9934e+00 -7.3580e-01 -9.2220e-01]\n",
      " [ 2.6088e+00  3.7980e-01 -1.4394e+00]\n",
      " [-1.2929e+00  8.7720e-01 -3.2423e+00]\n",
      " [-3.0750e-01 -2.5854e+00  2.4750e-01]\n",
      " [ 6.9200e-01 -2.0890e+00 -1.0319e+00]\n",
      " [-1.0943e+00 -2.1904e+00 -1.2614e+00]\n",
      " [ 2.1795e+00 -2.8241e+00 -3.8049e+00]\n",
      " [ 2.5176e+00 -1.9822e+00 -2.2914e+00]\n",
      " [ 2.9143e+00 -1.2135e+00 -3.8343e+00]\n",
      " [ 3.5220e-01 -2.0859e+00 -5.3307e+00]\n",
      " [ 1.0232e+00 -4.5200e-01 -5.4210e+00]\n",
      " [-6.6520e-01 -6.9670e-01 -4.9346e+00]]\n",
      "Here are the empty dictionary of attributes\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "print(f'Here are the list of atoms\\n{mol1.atoms}\\n')\n",
    "print(f'Here are the list of bonds\\n{mol1.bonds}')\n",
    "print(f'Here are the coordinates of the atoms\\n{mol1.coords}')\n",
    "print(f'Here are the empty dictionary of attributes\\n{mol1.attrib}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Atom class\n",
    "\n",
    "Individual atoms can be retrieved in a few different ways from the molecule:\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Atoms can be achieved via an index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_atom1 = mol1.get_atom(2)\n",
    "ex_atom1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Atoms can be retrieved via an element"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Atom(element=N, isotope=None, label='N', formal_charge=0, formal_spin=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_atom2 = mol1.get_atom(ml.Element.N)\n",
    "ex_atom2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Atoms can also be retrieved via an assigned label"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example atom 3: Atom(element=N, isotope=None, label='Important', formal_charge=0, formal_spin=0)\n",
      "Is example atom 2 = example atom 3? --> True\n"
     ]
    }
   ],
   "source": [
    "ex_atom2.label = \"Important\"\n",
    "ex_atom3 = mol1.get_atom(\"Important\")\n",
    "print(f'Example atom 3: {ex_atom3}')\n",
    "print(f'Is example atom 2 = example atom 3? --> {ex_atom2 == ex_atom3}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Atoms also have a few other important properties"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'element': N,\n",
       " 'isotope': None,\n",
       " 'label': 'Important',\n",
       " 'atype': <AtomType.sp3: 31>,\n",
       " 'stereo': <AtomStereo.Unknown: 0>,\n",
       " 'geom': <AtomGeom.Unknown: 0>,\n",
       " 'formal_charge': 0,\n",
       " 'formal_spin': 0,\n",
       " 'attrib': {},\n",
       " '_parent': <weakref at 0x7f9a5bfac900; to 'Molecule' at 0x7f99bb853d10>}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_atom2.as_dict()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Some other important functionality exists to allow quick retrieval of atoms and information regarding atoms.\n",
    "\n",
    "This example retrieves a tuple of atoms"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=O, isotope=None, label='O', formal_charge=0, formal_spin=0))"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "atoms_of_interest = mol1.get_atoms(7,8,9,10)\n",
    "atoms_of_interest"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example retrieves all atoms that are carbon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0),\n",
       " Atom(element=C, isotope=None, label='C', formal_charge=0, formal_spin=0))"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_carbon_atoms = mol1.get_atoms(*mol1.yield_atoms_by_element(ml.Element.C))\n",
    "all_carbon_atoms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example retrieves all atoms that contain the label \"Important\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(Atom(element=N, isotope=None, label='Important', formal_charge=0, formal_spin=0),)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mol1.get_atoms(*mol1.yield_atoms_by_label(\"Important\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This retrieves the index of an atom"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mol1.get_atom_index(ex_atom2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This retrieves the indices of atoms of interest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7, 8, 9, 10)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mol1.get_atom_indices(*atoms_of_interest)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition, atoms can be instantiated entirely independently of a `Molecule` object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Atom(element=Si, isotope=29, label=None, formal_charge=0, formal_spin=0)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Assigns Silicon to both a and b, but with different geometries and atom types\n",
    "a = ml.Atom(\"Si\", isotope=29, geom=ml.AtomGeom.R4_Tetrahedral)\n",
    "b = ml.Atom(\"Si\", isotope=29, atype=ml.AtomType.AttachmentPoint)\n",
    "print(a)\n",
    "b.is_attachment_point"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The elements of atoms can also be rapidly changed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Atom(element=Bi, isotope=29, label=None, formal_charge=0, formal_spin=0)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.element = 83\n",
    "a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Each `Atom` can also be assigned different attributes of common data types within python easily as though it were a dictionary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current attribute list for Example Atom A\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'List': [0, 1, 2],\n",
       " 'Tuple': ('a', 'b', 'c'),\n",
       " 'Dictionary': {'Data': (0.1, 0.2, 0.3)}}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(f'Current attribute list for Example Atom A')\n",
    "a.attrib[\"List\"] = [0,1,2]\n",
    "a.attrib[\"Tuple\"] = ('a','b','c')\n",
    "a.attrib[\"Dictionary\"] = {\"Data\": (0.1, 0.2, 0.3)}\n",
    "\n",
    "a.attrib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Coordinates of atoms or sets of atoms can quickly be retrieved from their associated atoms"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example Atom 2 Coordinates: [-1.0974 -0.4738  1.2059]\n",
      "All Carbon Atom subset:\n",
      "[[ 5.7300e-02 -2.2600e-02  2.1227e+00]\n",
      " [-1.0974e+00 -4.7380e-01  1.2059e+00]\n",
      " [-4.2840e-01 -4.1130e-01 -1.6870e-01]\n",
      " [ 8.6830e-01  3.5980e-01 -4.0000e-04]\n",
      " [ 2.4562e+00  4.4170e-01  1.8361e+00]\n",
      " [-2.4328e+00  2.6590e-01  9.8320e-01]\n",
      " [-2.6553e+00  2.4720e-01 -5.8010e-01]\n",
      " [-1.2428e+00  5.6260e-01 -1.0163e+00]\n",
      " [ 1.5353e+00  5.7900e-01 -1.4179e+00]\n",
      " [ 7.8200e-02  2.2291e+00 -2.2166e+00]\n",
      " [-5.9770e-01  8.5390e-01 -2.4020e+00]\n",
      " [ 7.6020e-01  1.6780e-01 -2.7001e+00]\n",
      " [ 7.8120e-01 -1.2141e+00 -3.3773e+00]\n",
      " [-2.8280e-01 -1.8835e+00 -5.9570e-01]\n",
      " [ 2.1775e+00 -1.8412e+00 -3.3215e+00]\n",
      " [ 3.4850e-01 -1.1006e+00 -4.8514e+00]]\n"
     ]
    }
   ],
   "source": [
    "atom2_coord = mol1.get_atom_coord(ex_atom1)\n",
    "print(f'Example Atom 2 Coordinates: {atom2_coord}')\n",
    "\n",
    "all_carbon_subset = mol1.coord_subset(all_carbon_atoms)\n",
    "print(f'All Carbon Atom subset:\\n{all_carbon_subset}')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dev-blake",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
